[hybi] WebSocket sub-protocol

Brodie Thiesfield <brofield@gmail.com> Thu, 14 October 2010 06:23 UTC

Return-Path: <brofield@gmail.com>
X-Original-To: hybi@core3.amsl.com
Delivered-To: hybi@core3.amsl.com
Received: from localhost (localhost [127.0.0.1]) by core3.amsl.com (Postfix) with ESMTP id 6C68C3A6AA9 for <hybi@core3.amsl.com>; Wed, 13 Oct 2010 23:23:25 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -2.599
X-Spam-Level:
X-Spam-Status: No, score=-2.599 tagged_above=-999 required=5 tests=[BAYES_00=-2.599]
Received: from mail.ietf.org ([64.170.98.32]) by localhost (core3.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lgic5P7oT8Yn for <hybi@core3.amsl.com>; Wed, 13 Oct 2010 23:23:24 -0700 (PDT)
Received: from mail-qw0-f44.google.com (mail-qw0-f44.google.com [209.85.216.44]) by core3.amsl.com (Postfix) with ESMTP id 086E73A6AA4 for <hybi@ietf.org>; Wed, 13 Oct 2010 23:23:23 -0700 (PDT)
Received: by qwc9 with SMTP id 9so3658721qwc.31 for <hybi@ietf.org>; Wed, 13 Oct 2010 23:24:42 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:date:message-id :subject:from:to:content-type; bh=14u2is5906DKyBSx9IcBE1/kFkde3/lT2ZVGeBIQ77w=; b=lNAkSZ3r7NyTw7zuxoqfCJ7qIdLozyLnPtNHCU6wZhbFsxdf9cEs7ZRcUriHEzfNtC EV57HqygKpQrz1Kz2jGQoWEBUlHW1SmJa1FUFZZZUFvz2qqC4JGfrhmRSGniGSRC5ZqV lSnqyNQuJWhVfS1LWbiJeVRUkxI8MtrV+uTwo=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=BZHqNwx10tyExArFdO3gXLyy1kM9dgyJ342ZvjRjsjXTOcioGt7hUVZJMK7fbZwd/2 ZTX4cnzfCpl9C6tlu/jsIo3MY42YKGU1ubsjd5WVCJ8Z2VYvthKRtm85+BGsBtyhSsit skfGNacOE5vHtP1xPwSCJZkQn34fMZQlpkQI0=
MIME-Version: 1.0
Received: by 10.229.183.8 with SMTP id ce8mr8410738qcb.288.1287037481721; Wed, 13 Oct 2010 23:24:41 -0700 (PDT)
Received: by 10.229.190.198 with HTTP; Wed, 13 Oct 2010 23:24:41 -0700 (PDT)
Date: Thu, 14 Oct 2010 15:24:41 +0900
Message-ID: <AANLkTinyVLn+6VrBr=nv-Mvggwn7-PZ2qiK6qm3qvyHY@mail.gmail.com>
From: Brodie Thiesfield <brofield@gmail.com>
To: hybi@ietf.org
Content-Type: text/plain; charset="ISO-8859-1"
Subject: [hybi] WebSocket sub-protocol
X-BeenThere: hybi@ietf.org
X-Mailman-Version: 2.1.9
Precedence: list
List-Id: Server-Initiated HTTP <hybi.ietf.org>
List-Unsubscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=unsubscribe>
List-Archive: <http://www.ietf.org/mail-archive/web/hybi>
List-Post: <mailto:hybi@ietf.org>
List-Help: <mailto:hybi-request@ietf.org?subject=help>
List-Subscribe: <https://www.ietf.org/mailman/listinfo/hybi>, <mailto:hybi-request@ietf.org?subject=subscribe>
X-List-Received-Date: Thu, 14 Oct 2010 06:23:25 -0000

The current WebSocket API specifies the ability for multiple protocols
to be specified in the constructor of the WebSocket object. The
current WebSocket protocol spec doesn't specifically preclude
specifying a list of protocols in the Sec-WebSocket-Protocol request
header, however it doesn't specify it either. The following changes to
the -02 spec text remedy this oversight.

-------------------------------
1.3. Opening handshake
page 9
replace the sentence "The |Sec-WebSocket-Protocol| field takes an
arbitrary string:", and the following paragraph with:

The Sec-WebSocket-Protocol request-header field can be used to
indicate what subprotocols (application-level protocols layered over
the WebSocket protocol) that are acceptable to the client. The server
selects one of the acceptable protocols and echoes that value in its
handshake to indicate that it has selected that protocol.

        Sec-WebSocket-Protocol: chat, superchat

-------------------------------
1.3. Opening handshake
page 11
replace the paragraph beginning "Option fields can also be included."
with the following:

   Option fields can also be included.  In this version of the protocol,
   the main option field is |Sec-WebSocket-Protocol|, which indicates
   the subprotocol that the server has selected.  Web browsers verify
   that the server included one of the values as was specified in the
   |WebSocket| constructor. A server that supports multiple
   subprotocols has to make sure it selects one based on the
   client's handshake and specifies it in its handshake.

        Sec-WebSocket-Protocol: chat

-------------------------------
1.9. Subprotocols using the WebSocket protocol
page 14, paragraph 1
Replace the sentence "If it is specified, the server needs to include
the same field and value in its response for the connection to be
established." with:

If it is specified, the server needs to include the same field and one
of the selected subprotocol values in its response for the connection
to be established.

-------------------------------
5.1. Client Requirements
page 28

Replace item 16 with:

   16.  If there is no /protocols/, then skip this step.

        Otherwise, generate the acceptable protocol string by joining
        each protocol in /protocols/ using a U+002C COMMA character
        followed by a U+0020 SPACE character. Add the string
        consisting of the concatenation of the string
        "Sec-WebSocket-Protocol:", a U+0020 SPACE character, and
        the acceptable protocol string generated above, to /fields/.

-------------------------------
5.1. Client Requirements
page 34

Replace the entry beginning "If the entry's name is
"sec-websocket-protocol" with:

        -> If the entry's name is "sec-websocket-protocol"
           If there was are /protocols/ specified, and the value is not
           exactly equal to one of the items in /protocols/, then fail
           the WebSocket connection and abort these steps.  (If
           no /protocols/ were specified, the field is ignored.)

-------------------------------
5.2.2. Sending the server's opening handshake
page 40

In the section "/subprotocol/", replace the sentence beginning "If the
server supports multiple subprotocols" with:

If the server supports multiple subprotocols, then the value should be
derived from the client's handshake, specifically by selecting one of
the values from the "Sec-WebSocket-Protocol" field.

-------------------------------

There doesn't appear to be a place to define it in the current spec,
but should it be added, I have included a description of this request
header. Using definitions from
<http://dev.w3.org/html5/websockets/#dom-websocket> is U+0021 to
U+007E and <http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2>:

Sec-WebSocket-Protocol = "Sec-WebSocket-Protocol" ":"
        protocol *( SP protocol )
protocol = 1*<any CHAR except CTLs, separators, or SP>

For more consistency with HTTP and the well-defined concept of
acceptance lists with quality values, and also making it easier for a
HTTP server to reuse the same code, I propose that the following
definition to have acceptance lists for the subprotocol. Note however
that since this also requires a change to the WebSocket API it may not
be possible or desirable.

Sec-WebSocket-Protocol = "Sec-WebSocket-Protocol" ":"
        1#( ( protocol )[ ";" "q" "=" qvalue ] )
protocol = token


Regards,
Brodie